zoom scrolling: Improve the previous fix
authorMatthias Clasen <mclasen@redhat.com>
Mon, 23 Feb 2015 12:28:40 +0000 (07:28 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 23 Feb 2015 12:28:40 +0000 (07:28 -0500)
As Sebastian pointed out, just resetting the initial slider
position was an incomplete fix, because it does not cause the
delta to be recomputed, which is important in this scenario,
because you've likely travelled some distance over the slider
before the long press kicks in.
Instead, explicitly record both the slider position and the
delta.

gtk/gtkrange.c

index bd95ee921747ddb0191d210bc70683eeea394863..277b78d683f963c464d381ca07f9a51bc64341ca 100644 (file)
@@ -2437,10 +2437,21 @@ gtk_range_long_press_gesture_pressed (GtkGestureLongPress *gesture,
                                       gdouble              y,
                                       GtkRange            *range)
 {
-  if (!range->priv->zoom)
+  GtkRangePrivate *priv = range->priv;
+
+  if (!priv->zoom)
     {
-      /* unset initial position so it can be calculated */
-      range->priv->slide_initial_slider_position = -1;
+      if (priv->orientation == GTK_ORIENTATION_VERTICAL)
+        {
+          priv->slide_initial_slider_position = priv->slider.y;
+          priv->slide_initial_coordinate_delta = y - priv->slider.y;
+        }
+      else
+        {
+          priv->slide_initial_slider_position = priv->slider.x;
+          priv->slide_initial_coordinate_delta = x - priv->slider.x;
+        }
+
       update_zoom_state (range, TRUE);
     }
 }